package org.chickymate.server.controller.command.dto;

import java.util.ArrayList;
import java.util.List;

import org.chickymate.client.model.UrlDTO;
import org.chickymate.server.model.Url;

public class GetPopularUrlsCommand extends DTOAbstractCommand {

	public List<UrlDTO> execute() {
		return asDTO(getCommentDao().getPopularUrls());
	}
	
	private List<UrlDTO> asDTO(List<Url> urls) {
		List<UrlDTO> urlsDTO = new ArrayList<UrlDTO>(urls.size());
		for(Url url : urls) {
			urlsDTO.add(url.asDTO());
		}
		return urlsDTO;
	}

}
